Skip to content

test: golden valuation fixture shared with recoupable/marketing#765

Open
sweetmantech wants to merge 1 commit into
mainfrom
tests/valuation-golden-fixture
Open

test: golden valuation fixture shared with recoupable/marketing#765
sweetmantech wants to merge 1 commit into
mainfrom
tests/valuation-golden-fixture

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Part of recoupable/chat#1850 (video/experience parity, item 2 — valuation derivation guard).

Why

The catalog valuation model is intentionally implemented twice: lib/catalog/computeValuationBand.ts here (server-side valuations) and computeCatalogValuation.ts in recoupable/marketing (the /valuation card computes its band client-side for the progressive in-card state). The constants are mirrored by comment-discipline only — nothing fails if one side drifts. This PR adds the guard.

What

  • lib/catalog/__tests__/fixtures/valuation-golden.json — canonical inputs → expected band cases derived independently from the published formula ($0.0035/stream, gross-ups 1.25/1.4/1.6, NLS = gross x 0.85 x 0.75, multiples 10/13/16, age = round(ms/365.25d) clamped >= 1, default 5y). Cases: the real verified 16.3B-stream catalog (age fallback), zero streams, a 10y catalog aged from its release date, and the 1y age clamp.
  • lib/catalog/__tests__/valuationGoldenFixture.test.ts — runs computeValuationBand against every case, asserting to within one cent. GREEN on first run against the existing implementation (zero divergence today).

Lockstep rule: this fixture's twin lives at marketing/lib/valuation/__tests__/fixtures/valuation-golden.json and the two files must stay byte-identical (SHA-1 a2c9737f167a25e3589b5d53fa4bf832d4f1e0bd). Any model change must update the fixture in BOTH repos in the same coordinated change, or one repo's CI goes red — which is the point.

Follow-up (out of scope): extract a true shared package so the formula exists once; until then this fixture is the divergence tripwire.

Verification

  • pnpm test — 714 files / 3,944 tests pass (4 new)
  • pnpm exec tsc --noEmit — 200 errors, identical to the pre-existing main baseline (none in touched files)

Siblings

Note: branch is tests/valuation-golden-fixture (not test/...) because this repo's long-lived test branch occupies that ref namespace.

🤖 Generated with Claude Code


Summary by cubic

Adds a shared “golden” valuation-band fixture and test to guard against drift between the server computeValuationBand and marketing’s client implementation. The byte-identical JSON is committed in both repos and CI asserts each case to the cent.

  • Migration
    • If the valuation formula or constants change, update the fixture in both repos in the same change.

Written for commit 69ac021. Summary will update on new commits.

Review in cubic

Guards the twin implementations of the catalog valuation model
(computeValuationBand here, computeCatalogValuation in marketing)
against silent divergence: a byte-identical fixture JSON is committed
in both repos and each repo's CI asserts its implementation reproduces
every case to the cent (chat#1850).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Ready Ready Preview Jul 7, 2026 11:23pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • lib/catalog/__tests__/fixtures/valuation-golden.json is excluded by !**/__tests__/** and included by lib/**
  • lib/catalog/__tests__/valuationGoldenFixture.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29215e0e-d22d-48b4-b4e3-883cbd7ad2a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tests/valuation-golden-fixture

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Test as Test Runner
    participant Fixture as valuation-golden.json
    participant Compute as computeValuationBand()
    participant MarketFixture as Marketing Twin Fixture
    participant CI as CI Pipelines

    Note over Test,Compute: NEW: Cross-repo divergence guard
    Test->>Fixture: Load cases from JSON
    loop For each case
        Test->>Compute: computeValuationBand(input)
        Compute-->>Test: { valuation, catalogAgeYears }
        Test->>Test: Compare catalogAgeYears
        Test->>Test: Compare low, mid, high (≤0.01)
    end
    alt All cases match
        Test-->>CI: Test passes
    else Any mismatch
        Test-->>CI: Test fails → divergence detected
        Note over CI,MarketFixture: Must update fixture in BOTH repos
    end
    Note over Fixture,MarketFixture: Byte-identical (SHA-1 check)
Loading

Auto-approved: Adds golden test fixture and test for valuation band calculation; no production code changed.

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant